<template>
  <div class="login">
    <div class="login-main">
      <h1 style="width: 330px;padding-top: 40px">欢迎来到后台管理系统</h1>
      <div class="ms-login">
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="60px">
          <el-form-item label="账号" prop="name" class="item">
            <el-input v-model="ruleForm.username" clearable>
              <i style="color:#0bdf6b;line-height: 50px" slot="prefix" class="el-icon-s-custom"></i>
            </el-input>
          </el-form-item>
          <el-form-item label="密码" prop="password">
            <el-input v-model="ruleForm.password" show-password clearable>
              <i style="color:#0bdf6b;line-height: 50px" slot="prefix" class="el-icon-lock"></i>
            </el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="submitForm('ruleForm')" round>登录</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>

export default {
  name: "Login",
  data() {
    return {
      ruleForm: {
        username: '',
        password: '',
      },
      rules: {
        username: [
          {required: true, message: '请输入账号', trigger: 'blur'},
          {min: 5, max: 13, message: '长度在 5 到 13 个字符', trigger: 'blur'}
        ],
        password: [
          {required: true, message: '请输入密码', trigger: 'blur'},
          {min: 5, max: 13, message: '长度在 5 到 13 个字符', trigger: 'blur'}
        ],
      }
    };
  },
  methods: {
    submitForm(formName) {
      const _this = this
      this.$refs[formName].validate((valid) => {
        if (valid) {
          //判断用户输入得信息是否正确。
          if(this.ruleForm.username==="admin" && this.ruleForm.password==="admin"){
            this.$router.push('Home')
            this.$message.success("登录成功");
          }else{

          }
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
  },
}
</script>

<style scoped>
.login {
  position: fixed;
  height: 100%;
  width: 100%;
  background-color: #cdeee8;
  text-align: center;
}

.ms-login {
  padding-top: 100px;
  padding-right: 30px;
  font-min-size: 30px;
}

.login-main {
  position: absolute;
  left: 50%;
  width: 300px;
  height: 160px;
  margin-left: -190px;
  /*margin-top: -150px;*/
  padding: 40px;
  border-radius: 10px;
  /*background-color: darkred;*/
}

>>> .el-form-item__label {
  padding-top: 10px;
  line-height: 30px;
  font-size: 17px;
}
/*>>>.el-form-item__label:before{*/
/*  content: '';*/
/*}*/
>>> .el-input {
  font-size: 18px;
}
>>>.el-form-item.is-required:not(.is-no-asterisk)>.el-form-item__label:before{
  content: '';
}
>>> .el-input__inner {
  border-radius: 10px;
  height: 50px;
  line-height: 50px;
  font-size: 20px;

}

>>> .el-button.is-round {
  width: 100%;
}
.switch{
  padding-bottom: 20px;
  padding-right: 30px;
}
</style>
